package com.syt.hospital.controller.api;

import com.syt.hospital.service.DepartmentService;
import com.syt.hospital.service.HospitalService;
import com.syt.hospital.service.HospitalSetService;
import com.syt.hospital.service.ScheduleService;
import com.syt.model.hospital.Hospital;
import com.syt.model.hospital.Schedule;
import com.syt.result.Result;
import com.syt.vo.hospital.DepartmentVo;
import com.syt.vo.hospital.HospitalQueryVo;
import com.syt.vo.hospital.ScheduleOrderVo;
import com.syt.vo.order.SignInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: xxx
 * @Date: 2023/2/19 10:22
 * @Description: 前台医院显示
 */
@Api(tags="前台医院显示")
@RestController
@RequestMapping("/api/hospital")
public class HospitalApiController {

    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private ScheduleService scheduleService;
    @Autowired
    private HospitalSetService hospitalSetService;

    @ApiOperation(value = "获取医院签名信息")
    @GetMapping("/inner/getSignInfoVo/{hoscode}")
    public SignInfoVo getSignInfoVo(@PathVariable String hoscode){
       return hospitalSetService.getSignInfoVo(hoscode);
    }

    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("/inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@PathVariable String scheduleId){
        return scheduleService.getScheduleOrder(scheduleId);
    }

    @ApiOperation(value = "根据排班id获取排班数据")
    @GetMapping("/getSchedule/{scheduleId}")
    public Result getScheduleById(@PathVariable String scheduleId){
          Schedule schedule= scheduleService.getScheduleById(scheduleId);
          return Result.ok(schedule);
    }



    @ApiOperation(value = "获取可预约排班数据")
    @GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getBookingSchedule(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Integer page,
            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Integer limit,
            @ApiParam(name = "hoscode", value = "医院code", required = true)
            @PathVariable String hoscode,
            @ApiParam(name = "depcode", value = "科室code", required = true)
            @PathVariable String depcode) {
        return Result.ok(scheduleService.getBookingScheduleRule(page, limit, hoscode, depcode));
    }

    @ApiOperation(value = "获取排班数据")
    @GetMapping("auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public Result findScheduleList(
            @ApiParam(name = "hoscode", value = "医院code", required = true)
            @PathVariable String hoscode,
            @ApiParam(name = "depcode", value = "科室code", required = true)
            @PathVariable String depcode,
            @ApiParam(name = "workDate", value = "排班日期", required = true)
            @PathVariable String workDate) {
        return Result.ok(scheduleService.getScheduleDetails(hoscode, depcode, workDate));
    }

    @ApiOperation(value = "根据医院编号获取医院预约挂号详情")
    @GetMapping("/getHospitalRegisteredByHoscode/{hoscode}")
    public Result getHospitalRegisteredByHoscode(@PathVariable String hoscode){
        Map<String,Object> map= hospitalService.getHospitalRegisteredByHoscode(hoscode);
        return Result.ok(map);
    }


    @ApiOperation(value = "根据医院编号获取科室")
    @GetMapping("/getDepartmentByHoscode/{hoscode}")
    public Result getDepartmentByHoscode(@PathVariable String hoscode){
        List<DepartmentVo> list = departmentService.getDepartmentList(hoscode);
        return Result.ok(list);
    }




    @ApiOperation(value = "根据医院名称模糊查询")
    @GetMapping("/findByHospName/{hosname}")
    public Result findByHospName(@PathVariable String hosname){
         List<Hospital> list= hospitalService.findByHospName(hosname);
         return Result.ok(list);
    }

    @ApiOperation(value = "查询医院列表")
    @GetMapping("/findHospList1/{page}/{limit}")
    public Result findHospitalList(@PathVariable int page,
                                   @PathVariable int limit,
                                   HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }
}
